<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title><?php echo isset($meta_title) ? $meta_title : C('APP_TITLE').' 写法规范';?></title>
    <style type="text/css">
        html,body,h1,h2,h3,h4,h5,h6,hr,p,iframe,dl,dt,dd,ul,ol,li,pre,form,fieldset,button,input,textarea,th,td{ margin:0; padding:0}
        body{ font-family:"微软雅黑",Arial,Verdana,Helvetica,sans-serif; font-size:14px; -webkit-text-size-adjust:none;}

        .mytable{ border:2px solid #00d049; width:100%; border-collapse:collapse;}
        .mytable th{ border:1px solid #00d049; padding:6px; font-size:12px; font-weight: bold; color:#ffffff; background-color: #00d049;}
        .mytable tr:hover{ background:#e9fff1;}
        .mytable td{ border:1px solid #00d049; font-size:12px; padding:6px 10px; text-align: left; vertical-align: top;}

        .mytable_2{ border:2px solid #5591ff; width:100%; border-collapse:collapse;}
        .mytable_2 th{ border:1px solid #5591ff; padding:6px; font-size:12px; font-weight: bold; color:#ffffff; background-color: #5591ff;}
        .mytable_2 tr:hover{ background:#edf3ff;}
        .mytable_2 tr.hide_tr:hover{ background:#ffffcc;}
        .mytable_2 td{ border:1px solid #5591ff; font-size:12px; padding:6px 10px; text-align: left; vertical-align: top;}
        .mytable_2 td.sub_title{ text-align: center; font-size: 14px; color: #5591ff;}
        .mytable_2 .bgc_ccddff{ background:#ccddff; }
        .mytable_2 td pre{ font-family:"微软雅黑",Arial,Verdana,Helvetica,sans-serif; font-size:14px; }

        .mytable_3{ border:2px solid #7300de; width:100%; border-collapse:collapse;}
        .mytable_3 th{ border:1px solid #7300de; padding:6px; font-size:12px; font-weight: bold; color:#ffffff; background-color: #7300de;}
        .mytable_3 tr:hover{ background:#f4e9ff;}
        .mytable_3 td{ border:1px solid #7300de; font-size:12px; padding:6px 10px; text-align: left; vertical-align: top;}

        .innerTable{ border:none; border-collapse:collapse;}
        .innerTable tr:hover{ background:#ffffcc;}
        .innerTable td{ border:none; font-size:12px; padding:0 6px; text-align: left; vertical-align: top;}

        .dsp_none{ display: none;}
        .plus{ display: block; width: 15px; height: 15px; line-height: 15px; text-align: center; border: 1px solid #000080; color: #000080; cursor: pointer;}
        .has_sub{ font-size: 40px!important; color: #FF0000;}
        .hide_tr{ background-color: #ffffcc;}

        .fontb{ font-weight: bold;}
        .font_const{ font-weight: bold; font-size: 14px!important; color: #da4e49;}

        .helper{ position:fixed; right:10px; top:50px; min-width:60px; border:2px solid #E9BA2F; background-color:#FFEEC2; }
        .helper ul{ list-style:none;}
        .helper ul li{ cursor:pointer; padding:0 10px; }
        .helper ul li:hover{ background-color:#FFE494;}

        .lh180pct{ line-height:180%;}
    </style>
</head>
<body>
    <table class="mytable_3" id="section_0">
        <tr>
            <th>约定</th>
        </tr>
        <tr>
            <td class="lh180pct">
                <h3>程序架构：</h3>
                1. 每个模块下只存在Controller、View层。<br>
                2. 公用Logic和Model层，全部放在Common下，并且按照不同功能分文件夹存放。<br>
                3. 自定义Controller、Logic、Model基类，常用的方法写入其中，减少程序冗余。<br>
                4. 不常用的函数，写到各自模块下的函数库。<br>
                5. 架构调整共同商议<br>
                6. 文档自行补充<br><br>
                <h3>写法规范：</h3>
                1. 原则是所有功能只写一遍，尽量不要冗余。<br>
                2. 每一步都要求对照日志，日志中不要出现Notice或Err。<br>
                3. Controller中的use关键字，一行声明一个，不要多个。<br>
                4. Logic层负责处理业务逻。<br>
                5. Model层负责数据增删改查。‘查’使用原生sql语句，‘增删改’统一采用TP提供的方法，尽量写法统一。<br>
                6. 模版统一采用PHP原生写法，添加编辑模版分开，利于维护。<br><br>
                <h3>数据表：</h3>
                1. 统一放在 Common\Base\TableBase.class.php 中，用函数 getTable($xxx) 调用表名<br>
                2. 表命名按照功能不同，取不同的前缀 <br><br>
                <h3>注意事项：</h3>
                1. 不同的子域名对应不同的模块<br>
            </td>
        </tr>
    </table>


    <table class="mytable_2" style="margin-top: 30px;" id="section_1">
        <tr>
            <th colspan="2">推荐写法</th>
        </tr>
        <!---->
        <tr>
            <td width="150" class="font_const">Controller</td>
            <td>参考: Admin\Controller\ArticleController.class.php</td>
        </tr>
        <tr>
            <td width="150" class="font_const">Logic</td>
            <td>参考: Common\Logic\Common\ArticleLogic.class.php</td>
        </tr>
        <tr>
            <td width="150" class="font_const">Model</td>
            <td>参考: Common\Model\Common\ArticleModel.class.php</td>
        </tr>
    </table>

    <table class="mytable" style="margin-top: 30px;" id="section_2">
        <tr>
            <th colspan="3">自定义常量</th>
        </tr>
        <tr>
            <td width="150" class="font_const">HTTP_HTTPS</td>
            <td><?php echo HTTP_HTTPS;?></td>
            <td>网址前缀 http://</td>
        </tr>
        <tr>
            <td class="font_const">DOMAIN</td>
            <td><?php echo DOMAIN;?></td>
            <td>站点域名</td>
        </tr>
        <tr>
            <td class="font_const">MODULE_DOMAIN</td>
            <td><?php echo MODULE_DOMAIN;?></td>
            <td>子模块域名，根据不同模块变化</td>
        </tr>
    </table>

    <table class="mytable_3" style="margin-top: 30px;" id="section_3">
        <tr>
            <th colspan="3">系统常量</th>
        </tr>
        <tr>
            <td width="150" class="font_const">NOW_TIME</td>
            <td><?php echo NOW_TIME;?></td>
            <td>当前时间戳</td>
        </tr>
        <tr>
            <td width="150" class="font_const">APP_PATH</td>
            <td><?php echo APP_PATH;?></td>
            <td>应用目录</td>
        </tr>
        <tr>
            <td width="150" class="font_const">COMMON_PATH</td>
            <td><?php echo COMMON_PATH;?></td>
            <td>公用目录</td>
        </tr>
        <tr>
            <td width="150" class="font_const">MODULE_NAME</td>
            <td><?php echo MODULE_NAME;?></td>
            <td>当前模块名</td>
        </tr>
        <tr>
            <td width="150" class="font_const">CONTROLLER_NAME</td>
            <td><?php echo CONTROLLER_NAME;?></td>
            <td>当前控制器名</td>
        </tr>
        <tr>
            <td width="150" class="font_const">ACTION_NAME</td>
            <td><?php echo ACTION_NAME;?></td>
            <td>当前操作名</td>
        </tr>
    </table>

    <table class="mytable_2" style="margin-top: 30px;" id="section_4">
        <tr>
            <th colspan="2">挂载点</th>
        </tr>
        <tr>
            <td width="150" class="font_const">app_init</td>
            <td>应用初始化标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">module_check</td>
            <td>模块检测标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">path_info</td>
            <td>PATH_INFO检测标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">app_begin</td>
            <td>应用开始标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">action_name</td>
            <td>操作方法名标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">action_begin</td>
            <td>控制器开始标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">view_begin</td>
            <td>视图输出开始标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">view_template</td>
            <td>视图模板解析标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">view_parse</td>
            <td>视图解析标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">template_filter</td>
            <td>模板解析过滤标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">view_filter</td>
            <td>视图输出过滤标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">view_end</td>
            <td>视图输出结束标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">action_end</td>
            <td>控制器结束标签位</td>
        </tr>
        <tr>
            <td width="150" class="font_const">app_end</td>
            <td>应用结束标签位</td>
        </tr>
    </table>

    <div class="helper">
        <ul>
            <li onclick="scrollToID('section_0');">约定</li>
            <li onclick="scrollToID('section_1');">推荐写法</li>
            <li onclick="scrollToID('section_2');">自定义常量</li>
            <li onclick="scrollToID('section_3');">系统常量</li>
            <li onclick="scrollToID('section_4');">挂载点</li>
        </ul>
    </div>

    <script type="text/javascript" src="/zui/lib/jquery/jquery.js"></script>
    <script type="text/javascript">
        function showHide(obj)
        {
            var obj = $(obj);
            var nx = obj.parent().parent().next();
            if(nx.is(':hidden')){
                obj.html('-');
                nx.show(300);
            }else{
                obj.html('+');
                nx.hide();
            }
        }
        function scrollToID(id, extra)
        {
            var pos = $('#'+id).position();
            extra = parseInt(extra); if(isNaN(extra)){ extra = 0; }
            $('html,body').animate({scrollTop:(pos.top+extra)}, '600');
        }
    </script>
</body>
</html>